home *** CD-ROM | disk | FTP | other *** search
- PROGRAM Create1; { (C) 1991 John C. Leon last updated 11/9/91 }
-
- {
- Creates an empty Btrieve file of record length 30 with 2 keys. This empty
- file is used in EXAMPLE1.PAS, and should be named EXAMPLE (no extension).
- }
-
- {$IFDEF production} {$D-,R-,L-,S-} {$ENDIF}
-
- USES
- BTP;
-
- VAR
- Counter,
- Counter1 : integer;
- MyFileSpec : PFileSpec;
- MyFileName : string;
-
- BEGIN
- MyFileSpec := new(PFileSpec);
- with MyFileSpec^ do
- begin
- {Create a fixed length, standard Btrieve file, with no pre-allocation }
- {and no alternate collating sequence. }
- RecLen := 30; FileFlags := 0;
- PageSize := 512; PreAlloc := 0;
- NumKeys := 2;
- fillchar(KeyArray, sizeof(KeyArray), 0); {This line is MANDATORY!}
- {Key #0}
- with KeyArray[0] do
- begin
- KeyPos := 11; KeyLen := 20;
- {recommend ALWAYS using ExtType in KeyFlags assignment}
- KeyFlags := Duplicates + Modifiable + ExtType;
- {Note that if KeyFlags includes Binary, the Binary flag bit will
- override any ExtKeyType you may set...and the key will be treated
- as an unsigned binary!!}
- ExtKeyType:= BString; {always assign a value to this element}
- end;
- {Key #1}
- with KeyArray[1] do
- begin
- KeyPos := 1; KeyLen := 10;
- KeyFlags := Duplicates + Modifiable + ExtKeyType;
- ExtKeyType := BString;
- end;
- end; {with MyFileSpec^ do}
-
- write('Enter name of file to create: ');
- readln(MyFileName);
- BStatus := CreateFile(MyFileName, MyFileSpec, ''); {'' = no alt col seq}
- dispose(MyFileSpec);
- if BStatus <> 0 then
- writeln('Error creating file. Status = ', BStatus)
- else
- begin
- for Counter := 1 to length(MyFileName) do
- MyFileName[Counter] := upcase(MyFileName[Counter]);
- writeln('File ', MyFileName, ' created successfully.');
- end;
-
- END.
-